/*
 * Author  : Leo <lipf160627@163.com>
 * Created : 2025-7-27
 * Desc    : Freertos tasks management
 */

#include "tasks.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"

#include "lcd_ui.h"
#include "utypes.h"
#include <stdint.h>

// LCD任务，创建一个queue，用于接收LCD数据
// 超声波任务，测距
// 语音识别任务
// 语音输出任务，创建一个queue，用于接收语音数据
// 体态控制任务

typedef struct {
    Lcd_Action_t   action;
    Lcd_FontSize_t size;
    struct {
        uint16_t xstart;
        uint16_t ystart;
        uint16_t xend;
        uint16_t yend;
    } address;
    struct {
        uint16_t height;
        uint16_t width;
    } area;
    struct {
        uint16_t fc;
        uint16_t bc;
    } color;
    void *data;
} LcdQueueData;

typedef struct {
    QueueHandle_t lcdQueue;
} GlobalResource_t;

// 创建全局queue、timer等资源
GlobalResource_t* tasks_init(void)
{
    QueueHandle_t lcdQueue = xQueueCreate(3, sizeof(LcdQueueData));
    if (lcdQueue == NULL)
    {
        return NULL;
    }

    GlobalResource_t *gResource = malloc(sizeof(GlobalResource_t));
    gResource->lcdQueue = lcdQueue;

    return gResource;
}

void lcdTask(void *pvParameters)
{
    while (1)
    {
        vTaskDelay(1000);
    }
}
